package lili.com.my.fragment;


import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import lili.com.my.R;
import lili.com.my.activity.LoginActivity;


public class MyFragment extends Fragment {

    private ImageView imageView;

    public MyFragment() {
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_my, container, false);
        imageView = view.findViewById(R.id.img);
        imageView.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                Log.i("MyFragment","Login");
                SharedPreferences sp=getActivity().getSharedPreferences("login", Context.MODE_PRIVATE);
                boolean islogin=sp.getBoolean("islogin",false);
                if (islogin){
                    Toast.makeText(getActivity(),"已经登录过了",Toast.LENGTH_SHORT).show();
                    return;
                }
                Intent intent=new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
            }
        });
        return view;
    }


}
